﻿using System.ComponentModel.Composition;
using Accountant.DataModel;
using Caliburn.Micro;

namespace Accountant.ViewModels
{
  [Export(typeof(AddCurrencyViewModel))]
  public class AddCurrencyViewModel : Screen
  {
    public AccountantContext Context { get; set; }
    public Currency CurrencyUnderCreation { get; private set; }

    public AddCurrencyViewModel(AccountantContext context)
    {
      Context = context;
      CurrencyUnderCreation = new Currency();
    }

    public void Accept()
    {
      Context.Currencies.Add(CurrencyUnderCreation);
      Context.SaveChanges();
      TryClose(true);
    }
    public void Cancel()
    {
      TryClose(false);
    }
  }
}